package com.situ.project1.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.situ.project1.mapper.CustomerMapper;
import com.situ.project1.pojo.Customer;
import com.situ.project1.service.CustomerService;
import com.situ.project1.util.PaginateInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author:yzy
 * @date:2024/8/10
 */
@Service
public class CustomerServiceImpl implements CustomerService {
    private CustomerMapper customerMapper;
    @Autowired
    public CustomerServiceImpl(CustomerMapper customerMapper) {
        this.customerMapper = customerMapper;
    }
    @Override
    public List<Customer> getAll(PaginateInfo pi, Customer customer) {
        try(Page<Customer> __ = PageHelper.startPage(pi.getPageNo(), pi.getPageSize())) {
            return customerMapper.getAll(customer);
        }
    }

    @Override
    public boolean add(Customer customer) {
        return customerMapper.add(customer);
    }

    @Override
    public boolean update(Customer customer) {
        return customerMapper.update(customer);
    }

    @Override
    public boolean delete(Integer[] ids) {
        return customerMapper.delete(ids);
    }

    @Override
    public Customer getUserCustomer(String username) {
        return customerMapper.getUserCustomer(username);
    }
}
